<%@page import="cn.jussi.dao.BaseDao"%>
<%@page import="cn.jussi.model.User"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
</head>
<body>

	<%
		BaseDao baseDao = new BaseDao();
		String userName = request.getParameter("username");
		String password = request.getParameter("password");
		String phoneNum = request.getParameter("phoneNum");
		String address = request.getParameter("address");
		java.util.Date regDate = new java.util.Date();
		
		//采用面向对象思想封装
		User user = new User();
		user.setUserName(userName);
		user.setPassword(password);
		user.setPhoneNum(phoneNum);
		user.setAddress(address);
		user.setRegDate(regDate);
		
		//防止代码注入
		String sql = "insert into users values(?,?,?,?,?)";
	
		int count = baseDao.IUD(sql, 
								user.getUserName(), 
								user.getPassword(), 
								user.getPhoneNum(), 
								user.getAddress(), 
								new java.sql.Date(user.getRegDate().getTime()));
		
		if(count > 0){
			out.println("插入成功");
		}
		
	%>

</body>
</html>